$(function () {
    //console.log(id);
    //获取url中的参数
    var announcementId = getQueryString("announcementId");

    console.log(announcementId);
    //根据id从数据库中获取修改前的值
    $.post(
        "/citrusmonitor/announce.do?method=showAnById&id="+announcementId,

        function (data) {
         $("#announcement_id").val(data.id),
	     $("#title").val(data.title),
	     $("#content").val(data.content)
	 /*    $("#createTime").val(data.create_time)*/
	   
        },
        "json"
    );
    //edit按钮绑定事件
    $("#edit").click(function () {

        $.post(
            "/citrusmonitor/announce.do?method=modifyAnnounce",
            {
            	"announcementId": $("#announcement_id").val(),
                "title": $("#title").val(),
                "content": $("#content").val()
             /*   "createTime": $("#create_time").val()*/
               
            },
           function(res){
                console.log(res);
                res = JSON.parse(res);
                if(res.status==1){
                    alert("信息提示修改成功");
                }else{
                    alert("信息提示修改失败");
                }}
        )
    })
})

function getQueryString(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    console.log(reg );
    var r = window.parent.document.getElementById("rightframe").contentWindow.location.search.substr(1).match(reg);
    if(r!=null){
        return  unescape(r[2]);
    }
    return null;
}
